package com.zjuee.web.ledger.service.impl.handledata;

import com.zjuee.core.translation.handledata.impl.AbstractDataHandler;
import com.zjuee.service.PlanCarryService;
import com.zjuee.vo.PlanCarryVo;
import com.zjuee.base.model.common.plan.PlanCarry;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

@Component(value = "planCarryHandle")
public class PlanCarryHandle extends AbstractDataHandler {
    @Resource
    private PlanCarryService planCarryService;

    @Override
    public <T> T getData(T data, Map<Object, Object> map, String... str) {
        PlanCarry planCarry = (PlanCarry) data;
        PlanCarryVo planCarryVo = new PlanCarryVo();
        BeanUtils.copyProperties(planCarry, planCarryVo);
        String companyName = planCarryService.getCompanyNameById(planCarry.getBciId());
        planCarryVo.setBciName(companyName);
        Integer wpcType = planCarry.getWpcType();
        if (wpcType == 11 || wpcType == 12) {
            planCarryVo.setWpcDirectory(map.get(planCarry.getWpcScode() + "" + str[5]) == null ? "" : map.get(planCarry.getWpcScode() + "" + str[5]).toString());
            planCarryVo.setWpcDisposeTypeStr(map.get(planCarry.getWpcDisposeType() + "" + str[0]) == null ? "" : map.get(planCarry.getWpcDisposeType() + "" + str[0]).toString());
            planCarryVo.setWpcDisposeStypeStr(map.get(planCarry.getWpcDisposeStype() + "" + str[1]) == null ? "" : map.get(planCarry.getWpcDisposeStype() + "" + str[1]).toString());
        } else {
            planCarryVo.setWpcDirectory(planCarryVo.getWpcName());
            planCarryVo.setWpcDisposeTypeStr(map.get(planCarry.getWpcDisposeType() + "" + str[3]) == null ? "" : map.get(planCarry.getWpcDisposeType() + "" + str[3]).toString());
            planCarryVo.setWpcDisposeStypeStr(map.get(planCarry.getWpcDisposeStype() + "" + str[4]) == null ? "" : map.get(planCarry.getWpcDisposeStype() + "" + str[4]).toString());
        }
        planCarryVo.setWpcTypeStr(map.get(planCarry.getWpcType() + "" + str[2]) == null ? "" : map.get(planCarry.getWpcType() + "" + str[2]).toString());
        return (T) planCarryVo;
    }
}
